package com.zhongyu.controller;

import com.zhongyu.pojo.OrderDetail;
import com.zhongyu.pojo.User;
import com.zhongyu.service.OrderDetailService;
import com.zhongyu.service.OrderService;
import com.zhongyu.vo.ResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/sal/xxddck")
public class XsOrderDetailController {
    @Resource
    private OrderService orderService;
    @Resource
    private OrderDetailService orderDetailService;
    @PostMapping("/chuku")
    public ResultVo doOutStore(@RequestBody OrderDetail orderDetail, HttpSession session) {
        try {
            User loginUser = (User) session.getAttribute("loginUser");
            Integer detailId = orderDetail.getId();
            Integer cangkuId = orderDetail.getStorehouseId();
          //  orderDetailService.doOutStore(loginUser.getId(), detailId, cangkuId);
            return   orderDetailService.doOutStore(loginUser.getId(), detailId, cangkuId);
        } catch (Exception e) {
            return ResultVo.failure("出库失败", e);
        }
    }
    }
